
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Main Tables"
clear
log using Table5.txt, text replace

***Robustness checks
***We start from the sample that includes the overlapping IPO attempts within the -2,+2 window
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_AllAttempts_Sep2024, replace
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Tables"
set matsize 10000

distinct id
*67 additional IPO attempts: 3,467+67=3,534

***Set of fixed effects
egen sic1year=group(sic1 year)
qui tabulate sic1year, generate(dsic1year)
egen month_post= group(month post)
qui tabulate month_post, generate(dmonth)
qui tabulate year_around_ipo, generate(deventyear) 

eststo clear 

***Column 1
**Including excluded IPOs 
 set more off
eststo:qui xtivreg2 wroa (IPO=instrument) deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*, fe first cluster(id) partial(deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*)
outreg2 using Table_robustness, keep(IPO) sortvar(IPO)  tex(frag) word bdec(3) nocons nor2 label ///
 addtext(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage,Specification, + excl. IPO)  replace
esttab,   keep(IPO) order(IPO) label se b(%9.3f) se(%9.3f) nor2 star(* 0.1 ** 0.05 *** 0.01) addnotes(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage,Specification, + excl. IPO)

eststo clear 
 
 
 
***Going back to the main sample, as it includes identifiers for firms with multiple non-overlapping events and CEM weights
***Main results
clear
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_MainSample_Sep2024, replace
set matsize 10000
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Tables"

***Set of fixed effects
egen sic1year=group(sic1 year)
qui tabulate sic1year, generate(dsic1year)
egen month_post= group(month post)
qui tabulate month_post, generate(dmonth)
qui tabulate year_around_ipo, generate(deventyear) 

*****Excluding firms with multiple (non-overlapping) events
distinct id if multiple_events==1

***Column 2
***Excluding firms with multiple events
 set more off
eststo:qui xtivreg2 wroa (IPO=instrument) deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* if multiple_events!=1, fe first cluster(id) partial(deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*)
outreg2 using Table_robustness, keep(IPO) sortvar(IPO)  tex(frag) word bdec(3) nocons nor2 label ///
 addtext(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage, Specification, - non-overlap attempts)
esttab,   keep(IPO) order(IPO) label se b(%9.3f) se(%9.3f) nor2 star(* 0.1 ** 0.05 *** 0.01) addnotes(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage, Specification, - non-overlap attempts)
eststo clear 

***Column 3
***Excluding cross-listed firms
tab cross_list
distinct id if cross_list==1

**Excluding cross-listed firms 
set more off
eststo:qui xtivreg2 wroa (IPO=instrument) deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* if cross_list!=1, fe first cluster(id) partial(deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*)
outreg2 using Table_robustness, keep(IPO) sortvar(IPO)  tex(frag) word bdec(3) nocons nor2 label ///
 addtext(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage, Specification, - cross-list)  
esttab,   keep(IPO) order(IPO) label se b(%9.3f) se(%9.3f) nor2 star(* 0.1 ** 0.05 *** 0.01) addnotes(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage, Specification, - cross-list) 
eststo clear 
 
 
***Column 4 
***Adding 2-digit x year FE
egen sic2year=group(sic2 year)
qui tabulate sic2year, generate(dsic2year) 

***************** 
set more off
eststo:qui xtivreg2 wroa (IPO=instrument) deventyear2 deventyear3 deventyear4 deventyear5 dsic2year* dmonth*, fe first cluster(id) partial(deventyear2 deventyear3 deventyear4 deventyear5 dsic2year* dmonth*)
outreg2 using Table_robustness, keep(IPO) sortvar(IPO)  tex(frag) word bdec(3) nocons nor2 label ///
 addtext(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage, Specification, + 2-dig-SIC x Year FE)   
esttab,   keep(IPO) order(IPO) label se b(%9.3f) se(%9.3f) nor2 star(* 0.1 ** 0.05 *** 0.01) addnotes(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage, Specification, + 2-dig-SIC x Year FE)   
eststo clear  
 
***Column 5  
***CEM
sum cem_weights
**Firms with a weight of 0 are those that do not have joint support in the distribution when matching to US firms.
**Some of these firms were excluded anyway due to colinearity

**CEM
set more off
eststo:qui xtivreg2 wroa (IPO=instrument) deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* [aweight = cem_weights], fe first cluster(id) partial(deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*)
outreg2 using Table_robustness, keep(IPO) sortvar(IPO)  tex(frag) word bdec(3) nocons nor2 label ///
 addtext(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage, Specification, CEM) 
esttab,   keep(IPO) order(IPO) label se b(%9.3f) se(%9.3f) nor2 star(* 0.1 ** 0.05 *** 0.01) addnotes(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage, Specification, CEM) 
eststo clear  
 
 
 
 
 
****Extended sample: Same IDs, but considering windows up to +4
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_ExtendedSample_Sep2024, replace
set matsize 10000


***Set of fixed effects
egen sic1year=group(sic1 year)
qui tabulate sic1year, generate(dsic1year)
egen month_post= group(month post)
qui tabulate month_post, generate(dmonth)
qui tabulate year_around_ipo, generate(deventyear) 

tab year_around_ipo
tab year_around_ipo if main_sample==1

**For replication package only (not in the paper)
***Showing that the sample size and results are identical to baseline specification when excluding events after t>2
set more off
eststo:qui xtivreg2 wroa (IPO=instrument) deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* if main_sample==1, fe first cluster(id) partial(deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*)
***
esttab,   keep(IPO) order(IPO) label se b(%9.3f) se(%9.3f) nor2 star(* 0.1 ** 0.05 *** 0.01) addnotes(Confirming main result -not shown) 
eststo clear 

***Column 6
***Extending the window to [-2,+3]
set more off
eststo:qui xtivreg2 wroa (IPO=instrument) deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* if year_around_ipo<4, fe first cluster(id) partial(deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*)
outreg2 using Table_robustness, keep(IPO) sortvar(IPO)  tex(frag) word bdec(3) nocons nor2 label ///
 addtext(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage,Instrument,Pre-IPO ret>0, Window, [-2:3]) 
esttab,   keep(IPO) order(IPO) label se b(%9.3f) se(%9.3f) nor2 star(* 0.1 ** 0.05 *** 0.01) addnotes(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage,Instrument,Pre-IPO ret>0, Window, [-2:3]) 
eststo clear 
 
***Column 7 
***Extending the window to [-2,+4]
set more off
eststo:qui xtivreg2 wroa (IPO=instrument) deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*, fe first cluster(id) partial(deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*)
outreg2 using Table_robustness, keep(IPO) sortvar(IPO)  tex(frag) word bdec(3) nocons nor2 label ///
 addtext(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage,Instrument,Pre-IPO ret>0, Window, [-2:4]) 
esttab,   keep(IPO) order(IPO) label se b(%9.3f) se(%9.3f) nor2 star(* 0.1 ** 0.05 *** 0.01) addnotes(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes,  IPO month x Post FE, Yes,Regression, Second stage,Instrument,Pre-IPO ret>0, Window, [-2:4]) 
eststo clear 
 
 
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Main Tables"
log close
 
 
 